﻿using Fvs_Service.Net;
using System.Net;
using System.Net.Sockets;

namespace Fvs_Service
{
    public class VirtualRelayHandler:ISocketHandler
    {
        public SocketPack Unpack(Socket socket, IPEndPoint remoteEndPoint, List<byte> buffer, int offset)
        {      
            if (buffer.Count == 8 && buffer[0] == 0x55)
            {
                byte id = buffer[2];
                if (id == (char)0x10||
                    id == (char)0x11||
                    id == (char)0x12)
                {
                    return new SocketPack
                    {
                        Result = AnalysisResult.Full,
                        Offset = 0,
                        Size = buffer.Count,
                        ProtocolId = 0,
                        TimeStamp = 0
                    };
                }
                else
                {
                    return new SocketPack{
                        Result = AnalysisResult.Empty,
                        Offset = 0,
                        Size = buffer.Count,
                        ProtocolId = 0,
                        TimeStamp = 0
                    };

                }
            }
            else
            {
                return new SocketPack
                {
                    Result = AnalysisResult.Empty,
                    Offset = 0,
                    Size = buffer.Count,
                    ProtocolId = 0,
                    TimeStamp = 0
                };
            }
        }
    }
}
